<?php

namespace app\admin\model\sign_up;

use think\Model;


class Programme extends Model
{

    

    

    // 表名
    protected $name = 'programme';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'people_number_text',
        'days_text',
        'type_text'
    ];
    

    
    public function getPeopleNumberList()
    {
        return ['1' => __('People_number 1'), '2' => __('People_number 2'), '3' => __('People_number 3'), '4' => __('People_number 4'), '5' => __('People_number 5'), '6' => __('People_number 6')];
    }

    public function getDaysList()
    {
        return ['1' => __('Days 1'), '2' => __('Days 2'), '3' => __('Days 3'), '4' => __('Days 4'), '6' => __('Days 6')];
    }

    public function getTypeList()
    {
        return ['1' => '铁血训练营', '2' => '忆群人团建', '3' => '海速体育', '4' => '其他'];
    }

    public function getTypeTextAttr($value,$data)
    {
        //$value = $value ? $value : (isset($data['course_type_id']) ? $data['course_type_id'] : '');
        $list = $this->getTypeList();
        return isset($list[$data['course_type_id']]) ? $list[$data['course_type_id']] : '';
    }

    public function getPeopleNumberTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['people_number']) ? $data['people_number'] : '');
        $list = $this->getPeopleNumberList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDaysTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['days']) ? $data['days'] : '');
        $list = $this->getDaysList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function type()
    {
        return $this->belongsTo('app\admin\model\course\Type', 'course_type_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function purpose()
    {
        return $this->belongsTo('app\admin\model\course\type\Purpose', 'course_type_purpose_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
